<html>
    <head>
        <title>localStorage</title>
        <script src="./localStorageCache.js"></script>
    </head>
    <body>
        <div>
            <button onclick="save()">存储一条信息</button>
            <button onclick="get()">获取一条信息</button>
            <button onclick="deleteItem()">删除一条信息</button>
        </div>
        <script>
            function save() {
                const key ='k1'
                const value = 'hello'
                // localStorage.setItem(key, value)
                localStorageCache.set(key, value, 2)
            }

            function get() {
                const key = 'k1'
                // const value = localStorage.getItem(key)
                const value = localStorageCache.get(key)
                console.log(key, value)
            }

            function deleteItem() {
                const key = 'k1'
                // localStorage.removeItem(key)
                localStorageCache.remove(key)
            }

        </script>
    </body>
</html>